﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EnemyShell : MonoBehaviour
{

    //public GameObject ShellExplosionprefb;
    public AudioClip ShellExplosionaududio;

  

    void Start()
    {
        GameObject.Destroy(this.gameObject, 5.0f);//子弹5S销毁
    }

    public void OnTriggerEnter(Collider collider)
    {
        //让子弹穿过奖励物品或者敌人，不做任何操作
        if (collider.tag == "Item"|| collider.tag == "Enemy")
            return;   

        if (collider.name == "Player")
            collider.SendMessageUpwards("TakeDamage");
        // GameObject.Instantiate(ShellExplosionprefb, transform.position, transform.rotation);
        AudioSource.PlayClipAtPoint(ShellExplosionaududio, transform.position);//播放击中声音
        GameObject.Destroy(this.gameObject);
    }
}
